﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;
using System.IO;

namespace vbReturn.classes
{
    public class xmlHelper
    {

        public static string getConfig()
        {
            string sErrorMsg = null;
            string sTest = null;

            try
            {
                
                XmlDocument doc = new XmlDocument();

                string sCurrentFilePath = Directory.GetCurrentDirectory() + @"\config\config.xml";
                doc.Load(sCurrentFilePath);
                string text = string.Empty;
                //get project property
                XmlNodeList xnlProj = doc.SelectNodes("/configuration/appSettings");
                foreach (XmlNode nodeProj in xnlProj)
                {
                    clsConfig.SProject = nodeProj["Project"].InnerText.ToString();
                    clsConfig.SStorer = nodeProj["Storer"].InnerText.ToString();
                    clsConfig.SEnvironment = nodeProj["Environment"].InnerText;

                    clsConfig.STestOracle = nodeProj["OracleTest"].InnerText;
                    clsConfig.SLiveOracle = nodeProj["OracleLive"].InnerText;

                    clsConfig.STestMSSQL = nodeProj["MSSQLTest"].InnerText;
                    clsConfig.SLiveMSSQL = nodeProj["MSSQLLive"].InnerText;

                    //Seeburger Test
                    clsConfig.SSeeBurgerDomainTest = nodeProj["SeeburgerDomainTest"].InnerText;
                    clsConfig.SSeeBurgerRGAPathTest = nodeProj["SeeburgerRGAPathTest"].InnerText;
                    clsConfig.SSeeBurgerIDTest = nodeProj["SeeburgerIDTest"].InnerText;
                    clsConfig.SSeeBurgerPasswordTest = nodeProj["SeeburgerPasswordTest"].InnerText;

                    //Seeburger Live
                    clsConfig.SSeeBurgerDomainLive = nodeProj["SeeburgerDomainLive"].InnerText;
                    clsConfig.SSeeBurgerRGAPathLive = nodeProj["SeeburgerRGAPathLive"].InnerText;
                    clsConfig.SSeeBurgerIDLive = nodeProj["SeeburgerIDLive"].InnerText;
                    clsConfig.SSeeBurgerPasswordLive = nodeProj["SeeburgerPasswordLive"].InnerText;

                    if (nodeProj["DeleteRGAExcelFile"].InnerText.ToUpper() == "YES")
                    {
                        clsConfig.BDeleteRGAExcelFile = true;
                    }
                    else
                    {
                        clsConfig.BDeleteRGAExcelFile = false ;
                    }

                    
                }
            }
            catch (Exception ex)
            {
                sErrorMsg = ex.Message;
            }

            return sErrorMsg;
         }
    }
}
